<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #a {
      width: 300px;
      height: 300px;
      background: #f00;
    }

    #b {
      width: 200px;
      height: 200px;
      background: #0f0;
    }

    #c {
      width: 100px;
      height: 100px;
      background: #00f;
    }
  </style>
</head>

<body>

  <div id="app">
    <div id="a" @click="log('a')">a
      <div id="b" @click="log('b')">b
        <div id="c" @click.stop="log('c')">c</div>
      </div>
    </div>
    <!-- <button v-on:click="clickHandler">点我点我点我🤪</button>
    <button @click="clickHandler">点我点我点我🤪</button> -->
    姓名：<input type="text" v-model="name">
    成绩：<input type="text" v-model="grade">
    <button @click="add">+++</button>
    <ul>
      <li v-for="(item, index) in list" :key="index" @click="getGrade(item,$event)">
        <span> {{item.name}} </span>
        <span> {{item.grade}} </span>
      </li>
    </ul>

  </div>
  <!-- 引入vue文件 -->
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        list: [
          { name: '小明', grade: 66 },
          { name: '小刚', grade: 99 },
          { name: '小花', grade: 88 },
          { name: '小傻', grade: 100 },
        ],
        name: '',
        grade: ''
      },
      methods: {
        clickHandler() {
          console.log(666);
        },
        getGrade(student, aa) {
          console.log(student.grade);
          // 事件对象
          console.log(event.target);
          console.log(aa.target);
        },
        add() {
          this.list.push({
            name: this.name,
            grade: this.grade,
          })
          this.name = ''
          this.grade = ''
        },
        log(msg) {
          // event.stopPropagation()
          console.log(msg);
        }
      }
    })

  </script>
</body>

</html>